package com.moss.cloud.base.biz.controller;

import com.moss.cloud.base.api.model.from.BaseFrom;
import com.moss.cloud.base.api.model.from.UserPositionFrom;
import com.moss.cloud.base.api.model.param.BasePageParam;
import com.moss.cloud.base.biz.service.ISysUserPositionService;
import com.moss.cloud.common.core.constant.ServiceList;
import com.moss.cloud.common.core.model.Result;
import com.moss.cloud.common.security.annotation.SysLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(ServiceList.BASE + "/sysUserPosition")
public class SysUserPositionController {
    private final ISysUserPositionService sysUserPositionService;

    public SysUserPositionController(ISysUserPositionService sysUserPositionService) {
        this.sysUserPositionService = sysUserPositionService;
    }

    /**
     * 指定用户职位查询
     *
     * @param basePageParam
     * @return
     */
    @PostMapping("/userPositionPage")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "指定用户职位查询")
    public Result<?> userPositionPage(@RequestBody @Validated BasePageParam basePageParam){
        return Result.success(sysUserPositionService.userPositionPage(basePageParam));
    }

    /**
     * 用户转岗
     *
     * @param userPositionFrom
     * @return
     */
    @PostMapping("/transfer")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "用户转岗")
    public Result<?> transfer(@RequestBody @Validated UserPositionFrom userPositionFrom){
        return Result.success(sysUserPositionService.transfer(userPositionFrom));
    }

    /**
     * 用户岗位
     *
     * @param baseFrom
     * @return
     */
    @PostMapping("/userPositions")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "用户岗位")
    public Result<?> userPositions(@RequestBody @Validated BaseFrom baseFrom){
        return Result.success(sysUserPositionService.userPositions(baseFrom));
    }
}
